package com.example.day1210_section_information.Provider;

import com.example.day1210_section_information.ResourceTable;
import ohos.agp.components.*;
import ohos.app.Context;

public class GuidePageProvide extends PageSliderProvider {

    private int[] mUrl = new int[]{ResourceTable.Media_bg_guide1, ResourceTable.Media_bg_guide2, ResourceTable.Media_bg_guide3};

    private Context mContext;

    public GuidePageProvide(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return mUrl.length;
    }

    @Override
    public Object createPageInContainer(ComponentContainer componentContainer, int i) {
        Component component = LayoutScatter.getInstance(mContext).parse(ResourceTable.Layout_item_guide_page, null, false);
        Image image = component.findComponentById(ResourceTable.Id_item_guide_img);
        int imgUrl = mUrl[i];
        image.setPixelMap(imgUrl);

        componentContainer.addComponent(component);

        return component;
    }

    @Override
    public void destroyPageFromContainer(ComponentContainer componentContainer, int i, Object o) {
        componentContainer.removeComponent((Component) o);
    }

    @Override
    public boolean isPageMatchToObject(Component component, Object o) {
        return true;
    }
}
